package model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;

@Entity(name="Vendedor")
public class Vendedor implements Serializable {

	private static final long serialVersionUID = 7403722808805861487L;
	
	private Long codigo;
	private String nome;
	private Date dataAdmissao;
	private Farmacia farmacia;
	private Collection<Venda> vendas;
	
	@Column(name="VENDEDOR_ID")
	@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getCodigo() {
		return codigo;
	}
	
	public void setCodigo(Long codigo) {
		this.codigo = codigo;
	}
	
	@NotNull(message="Informe o nome do vendedor")
	public String getNome() {
		return nome;
	}
	
	public void setNome(String nome) {
		this.nome = nome;
	}
	
	@Past @Temporal(TemporalType.DATE)
	public Date getDataAdmissao() {
		return dataAdmissao;
	}
	
	public void setDataAdmissao(Date dataAdmissao) {
		this.dataAdmissao = dataAdmissao;
	}
	
	@ManyToOne
	@JoinColumn(name="FARMACIA_ID")
	public Farmacia getFarmacia() {
		return farmacia;
	}
	
	public void setFarmacia(Farmacia farmacia) {
		this.farmacia = farmacia;
	}
	
	@OneToMany(mappedBy="vendedor")
	public Collection<Venda> getVendas() {
		return vendas;
	}
	
	public void setVendas(Collection<Venda> vendas) {
		this.vendas = vendas;
	}
}
